/**
 * <p>Copyright (c) 2011 深圳市鹏途信息技术有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	东莞交通工程质量监督综合业务系统        </p>
 * <p>创建者   :	adolf 
 * 
 * <p>描   述  :   AssetsManager.java for com.pengtu.service.asset    </p>
 * 
 * <p>最后修改 : $: 2011-8-15-上午11:52:27 v 1.0.0	 adolf   $     </p>
 * 
 */

package com.pengtu.service.asset;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.dao.Page;
import com.pengtu.dao.QueryFilter;
import com.pengtu.dao.asset.office.AssetInforDao;
import com.pengtu.dao.asset.office.AssetRecordDao;
import com.pengtu.entity.asset.office.Information;
import com.pengtu.entity.asset.office.Record;

/**
 * 
 * AssetsManager
 * 
 * 2011-8-15 上午11:52:27
 * 
 * @version 1.0.0
 * 
 */
@Component
@Transactional
public class AssetsManager {

	private AssetInforDao assetinforDao;
	private AssetRecordDao assetrecordDao;

	// Information Manager //
	@Transactional(readOnly = true)
	public Information getInformation(String id) {
		return assetinforDao.get(id);
	}

	@Transactional(readOnly = true)
	public List<Information> getAllInformation() {
		return assetinforDao.getAll();
	}

	@Transactional(readOnly = true)
	public Page<Information> findPageAsset(final Page<Information> page,
			final QueryFilter queryFilter) {
		// TODO Auto-generated method stub
		return assetinforDao.findPage(page, queryFilter);
	}

	public void saveInformation(Information information) {
		assetinforDao.save(information);
	}

	public void deleteInformation(String id) {
		assetinforDao.delete(id);
	}

	/**
	 * 
	 * isUniqueCode: 适用:验证是够唯一
	 * 
	 * @param newCode
	 * @param oldCode
	 * @return
	 * @exception
	 * @since 1.0.0
	 */
	public boolean isUniqueCode(String newCode, String oldCode) {
		// TODO Auto-generated method stub
		return assetinforDao.isPropertyUnique("code", newCode, oldCode);
	}

	@Autowired
	public void setInformationDao(AssetInforDao assetinforDao) {
		this.assetinforDao = assetinforDao;
	}

	// Record Manager //
	@Transactional(readOnly = true)
	public Record getRecord(String id) {
		return assetrecordDao.get(id);
	}

	@Transactional(readOnly = true)
	public List<Record> getAllRecord() {
		return assetrecordDao.getAll();
	}

	@Transactional(readOnly = true)
	public Page<Record> findPageRecord(final Page<Record> page,
			final QueryFilter queryFilter) {
		// TODO Auto-generated method stub
		return assetrecordDao.findPage(page, queryFilter);
	}

	public void saveRecord(Record record) {
		assetrecordDao.save(record);
	}

	public void deleteRecord(String id) {
		assetrecordDao.delete(id);
	}

	@Autowired
	public void setRecordDao(AssetRecordDao recordDao) {
		this.assetrecordDao = recordDao;
	}

}
